<%@ page language="java" isELIgnored="false" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <script type="text/javascript">
  		var path = "<%=basePath%>";
  	</script>
    <title>System Menu Tree</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="stylesheet" href="<%=basePath%>resources/tree/css/org_style.css" />
	<!-- 动态树 -->
	<jsp:include page="/resources/resource-refer/component-dynamictree-reference.jsp" />
	<!-- 系统通用资源 -->
	<jsp:include page="/resources/resource-refer/common-resource-reference.jsp" />
  </head>
  
  <body style="height: 100%;width: 100%;overflow: no;">
    <table border="0" cellpadding="0" width="100%" height="100%" cellspacing="0" class="zuo-left">
		<tr><td id="nodeManage_tree" ></td></tr>
	</table>
	<script type="text/javascript">
		var tree;
		tree = new dhtmlXTreeObject("nodeManage_tree","100%","100%",0);
		tree.setImagePath("<%=basePath%>resources/tree/org_tree_img/");
		$.getJSON(path+"basic/menuActionJson!queryRootMenuTree.do?date="+new Date(),function(data){
			tree.loadJSONObject(data);
		});
		//子节点数据异步加载
		tree.attachEvent("onOpenEnd",function(nodeId, event){
			//event是记录展开/合拢动作，-1为合拢  还有0、1；
			if(event != -1) {
				tree.deleteChildItems(nodeId);//删除当前节点下的所有子节点
				$.getJSON(path+"basic/menuActionJson!queryChildMenuTree.do?date="+new Date(), {
					menuID: nodeId
				}, function(data){
					tree.loadJSONObject(data);
				});
			}
		});
		//设置树节点鼠标双击响应
<%--		tree.setOnDblClickHandler(function(nodeID){--%>
<%--			//选中双击树节点--%>
<%--			tree.selectItem(nodeID,"","");--%>
<%--			//openState是记录展开/合拢动作，-1为合拢  1为展开；--%>
<%--			var openState = tree.getOpenState(nodeID);--%>
<%--			if(openState == -1) { --%>
<%--				tree.deleteChildItems(nodeID);//删除当前节点下的所有子节点--%>
<%--				$.getJSON(path+"basic/menuActionJson!queryChildMenuTree.do?date="+new Date(), {--%>
<%--					menuID: nodeID--%>
<%--				}, function(data){--%>
<%--					tree.loadJSONObject(data);--%>
<%--				});--%>
<%--				tree.openItem(nodeID);--%>
<%--			} else if(openState == 1) {--%>
<%--				tree.closeItem(nodeID);--%>
<%--			}--%>
<%--		});--%>
		
		//缺陷：单击事件两次响应双击事件
		tree.setOnClickHandler(function(nodeID) {
			//选中树节点
			tree.selectItem(nodeID,"","");
			//读取菜单的链接
			var menuAction = tree.getUserData("menuAction", nodeID);
			if(menuAction!=null && menuAction!="") {
				parent.window.frames["c_content_content"].location=path+menuAction+"?date="+new Date();
			}
		});
	</script>
  </body>
</html>
